import type { Ref } from 'vue';
import { provide, inject, ComputedRef } from 'vue';
import { BasicProps } from '../types/basicMap.ts';

declare type Recordable<T = any> = Record<string, T>;
type Instance = {
    wrapRef: Ref<HTMLDivElement | null>;
    getBindValue: ComputedRef<Recordable>;
};
type RetInstance = Omit<Instance, 'getBindValues'> & {
    getBindValues: ComputedRef<BasicProps>;
};
const key = Symbol('basic-map');

export function createBasicMapContext(instance: Instance) {
    provide(key, instance);
}

export function useBasicMapContext() {
    return inject(key) as RetInstance;
}
